/**
 * @author:Chang.Cook[at]gmail.com
 * 
 * a very simple, easy to use plugin base on jQuery
 * by haaway studio http://www.haaway.com
 * @license:LGPL
 */
(function($){
	
	var JHW = {};
	JHW.ver = '0.1.1';//20110801
	JHW.options={
		title:'demo title',
		content:'demo content',
		bg: true,//if show background 
		hide:'', //'' | 'slow' | 'fast'	| Millisecond number	
		onclose: null // callback func
	};
	JHW.html_hw_box_bg = '<div class="hw-box-bg"></div>';
	JHW.html_hw_box = '<div class="hw-box"><div class="hw-box-title"><span class="hw-box-title-content"></span><a class="hw-box-title-close" href="javascript:void(0)">X</a></div><div class="hw-box-content"></div></div>';
	JHW.alert = function(opts){
		var opts = $.extend(JHW.options, opts);
		//console.debug(opts);
		if(opts.bg){$('body').append(JHW.html_hw_box_bg);$('.hw-box-bg').css({width:$(document).width()});}
		
		$('body').append(JHW.html_hw_box);
		//compulate position pixels
		var _parr=initPos();
		$('.hw-box').css({left:_parr[0]+'px',top:_parr[1]+'px'});
		$('.hw-box-title-content').html( opts.title);
		$('.hw-box-content').html(opts.content );
		$('.hw-box-title-close').click(function(){
			$('.hw-box').hide(opts.hide); if($('.hw-box-bg')) $('.hw-box-bg').hide();
			if(opts.onclose){ opts.onclose(opts);}
		})
		.focus();
	};
	
	//compulate position pixels
	function initPos(){
		var pTop = $(document).scrollTop()+100, pLeft = ($(document).width()-$('.hw-box').width())/2;
		return [pLeft,pTop ];
	}
	
	if(window.JHW === undefined) window.JHW = JHW;
})(jQuery);
